Skip to content
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

regression: crasher with higher kinded types and scope escape checking #4312

Closed
scabug opened this issue Mar 4, 2011 · 3 comments
Closed

Comments

@scabug
Copy link

scabug commented Mar 4, 2011

This appears specific to higher kinded types.

class Bop[A[_]]

object Foo {
  private val stToSK = new Bop[ScopedTaskKey]
  private type ScopedTaskKey[T] = String
}
error: java.lang.Error: unexpected alias type: type ScopedTaskKey
	at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:35)
	at scala.tools.nsc.symtab.Symbols$$Symbol.existentialBound(Symbols.scala:970)
	at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$39.apply(Typers.scala:2743)
	at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$39.apply(Typers.scala:2738)
	at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:241)
	at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:241)
	at scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:61)  
	at scala.collection.immutable.List.foreach(List.scala:45)
	at scala.collection.TraversableLike$$class.map(TraversableLike.scala:241)
	at scala.collection.immutable.List.map(List.scala:45)
	at scala.tools.nsc.typechecker.Typers$$Typer.existentialTransform(Typers.scala:2738)
	at scala.tools.nsc.typechecker.Typers$$Typer.packSymbols(Typers.scala:2763)
	at scala.tools.nsc.typechecker.Typers$$Typer$$checkNoEscaping$$.check(Typers.scala:354)
	at scala.tools.nsc.typechecker.Typers$$Typer$$checkNoEscaping$$.locals(Typers.scala:341)
	at scala.tools.nsc.typechecker.Typers$$Typer.typedDefDef(Typers.scala:1690)
	at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3807)

If stToSK is not private, we can see the potential issue it is investigating when it crashes.

0304.scala:9: error: private type ScopedTaskKey escapes its defining scope as part of type Bop[Foo.ScopedTaskKey]
  val stToSK = new Bop[ScopedTaskKey]
      ^
one error found  

It compiles in 2.8.1, fails with r24371.

@scabug
Copy link
Author

scabug commented Mar 4, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4312?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Mar 4, 2011

@ingoem said:
Could you have a look whether that's for you Adriaan? Feel free to reassign.

@scabug
Copy link
Author

scabug commented Jun 20, 2011

@adriaanm said:
as in [#SI-4559], this requires clarification of expected behaviour for avoiding escaping symbols

I'd say checkNoEscape(sym) should not have to be called when sym.isAliasType, since normalisation could be used to chase away type aliases (private or otherwise) -- in principle, we only need to check the normalisation. The problem here arises due to a private type constructor alias, which requires eta-expansion to normalise. Eta-expansion yields a polytype, which is not directly expressible in the surface syntax (unless the alias was applied to its type arguments).

This issue shows that we currently use dealias instead of normalize, hence the need for a type constructor to trigger the problem: these have to be eta-expanded. The argument from [#SI-4559] remains the same, in principle, but it depends on the spec...

For now, only fixing the crasher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants