forked from scala/scala
    
        
        - 
        Couldn't load subscription status. 
- Fork 1
SI-7038 Deskolemize harder #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Type in expressions to have them evaluated. | ||
| Type :help for more information. | ||
|  | ||
| scala> def foo[S] = { type X = List[S]; List():X } | ||
| foo: [S]=> List[S] | ||
|  | ||
| scala> val li = foo[Int] | ||
| li: List[Int] = List() | ||
|  | ||
| scala> li: List[Int] | ||
| res0: List[Int] = List() | ||
|  | ||
| scala> type TL = List[Int] | ||
| defined type alias TL | ||
|  | ||
| scala> def foo = null: TL | ||
| foo: TL | ||
|  | ||
| scala> def foo = {type TL=List[Int]; null: TL} | ||
| foo: TL | ||
|  | ||
| scala> foo: List[Int] | ||
| res1: List[Int] = null | ||
|  | ||
| scala> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import scala.tools.partest.ReplTest | ||
|  | ||
| object Test extends ReplTest { | ||
|  | ||
| override def code = """ | ||
| def foo[S] = { type X = List[S]; List():X } | ||
| val li = foo[Int] | ||
| li: List[Int] | ||
| type TL = List[Int] | ||
| def foo = null: TL | ||
| def foo = {type TL=List[Int]; null: TL} | ||
| foo: List[Int] | ||
| """.trim | ||
| } | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd
dealiasinstead ofnormalize(and only if !(tp.dealias =:= tp) -- i.e., when arguments are supplied so that we don't have to eta-expand to a polytype)otherwise, looks good
EDIT: I think
tp.dealias match { ... }should work, no need for the case for alias typesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lukas's latest PR actually removed this custom
TypeMapin favour of a straightrestpe.substSyms(skolems, tparams). Which got me to thinking about how this version might be expressed in the same way; which other custom type maps could be expressed in the same way, etc.What I'm thinking of is
dealiasLocals(method, restpe).substSyms(skolems, tparams), wheredealiasLocalswould dealias any types aliases that are local to the method. Does that sound like a reasonable approach? How would I build such a thing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem is sym.deSkolemize doesn't have an inverse, so you can't easily determine the skolems list
for sym in skolems. TR(pre, sym, as) -> TR(NoPrefix, sym.deSkolemize, args)skolems = {sym | sym.deSkolemize in tparams}the only way I can see to express this as a substitution is to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what @lrytz is up to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that still goes from skolem to non-skolem
i don't know how to go from non-skolem to (original) skolem