-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-8708 Fix pickling of LOCAL_CHILD child of sealed classes
When a sealed class or trait has local children, they are not pickled in as part of the children of the symbol (introduced in 12a2b3b to fix Aladdin bug 1055). Instead the compiler adds a single child class named LOCAL_CHILD. The parents of its ClassInfoType were wrong: the first parent should be a class. For sealed traits, we were using the trait itself. Also, the LOCAL_CHILD dummy class was entered as a member of its enclosing class, which is wrong: it represents a local (non-member) class, and it's a synthetic dummy anyway.
- Loading branch information
Showing
11 changed files
with
122 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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,7 @@ | ||
Test_1.scala:2: warning: match may not be exhaustive. | ||
It would fail on the following input: (_ : this.<local child>) | ||
def foo(t: A.T) = t match { | ||
^ | ||
error: No warnings can be incurred under -Xfatal-warnings. | ||
one warning found | ||
one error found |
This file contains 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 @@ | ||
-Xfatal-warnings |
This file contains 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,6 @@ | ||
object A { | ||
sealed trait T { def f: Int } | ||
class TT extends T { def f = 0 } | ||
|
||
def foo = new T { def f = 1 } // local subclass of sealed trait T | ||
} |
This file contains 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,5 @@ | ||
object Test { | ||
def foo(t: A.T) = t match { | ||
case a: A.TT => 0 | ||
} | ||
} |
This file contains 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,6 @@ | ||
sealed trait \/[+A, +B] | ||
|
||
sealed trait EitherT[F[+_], +A, +B] | ||
object EitherT { | ||
def apply[F[+_], A, B](a: F[A \/ B]): EitherT[F, A, B] = new EitherT[F, A, B] { val run = a } | ||
} |
This file contains 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,13 @@ | ||
import scala.language.higherKinds | ||
|
||
trait ClientTypes[M[+_]] { | ||
final type Context[+A] = EitherT[M, String, A] | ||
object Context { | ||
def apply[A](ca: M[String \/ A]): Context[A] = EitherT[M, String, A](ca) | ||
} | ||
|
||
final type StatefulContext[+A] = EitherT[Context, String, A] | ||
object StatefulContext { | ||
def apply[A](state: Context[String \/ A]): StatefulContext[A] = ??? | ||
} | ||
} |
This file contains 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,8 @@ | ||
Scope{ | ||
def <init>: <?>; | ||
sealed abstract trait T extends ; | ||
def foo: <?> | ||
} | ||
Scope{ | ||
def f: <?> | ||
} |
This file contains 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,8 @@ | ||
package p | ||
|
||
class C { | ||
|
||
sealed trait T { def f: Int } | ||
|
||
def foo: T = new T { def f = 1 } | ||
} |
This file contains 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,21 @@ | ||
import scala.tools.partest._ | ||
import java.io.{Console => _, _} | ||
|
||
object Test extends DirectTest { | ||
|
||
override def extraSettings: String = "-usejavacp -cp " + testOutput.path | ||
|
||
override def code = "" | ||
|
||
override def show(): Unit = { | ||
val g = newCompiler() | ||
withRun(g)(r => { | ||
val c = g.rootMirror.getRequiredClass("p.C") | ||
println(c.info.decls) | ||
val t = c.info.member(g.newTypeName("T")) | ||
// this test ensrues that the <local child> dummy class symbol is not entered in the | ||
// scope of trait T during unpickling. | ||
println(t.info.decls) | ||
}) | ||
} | ||
} |