Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-7596 Curtail overloaded symbols during unpickling
In code like: object O { val x = A; def x(a: Any) = ... } object P extends O.x.A The unpickler was using an overloaded symbol for `x` in the parent type of `P`. This led to compilation failures under separate compilation. The code that leads to this is in `Unpicklers`: def fromName(name: Name) = name.toTermName match { case nme.ROOT => loadingMirror.RootClass case nme.ROOTPKG => loadingMirror.RootPackage case _ => adjust(owner.info.decl(name)) } This commit filters the overloaded symbol based its stability unpickling a singleton type. That seemed a slightly safer place than in `fromName`.
- Loading branch information
Showing
7 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
trait Driver { | ||
abstract class Table | ||
} | ||
|
||
object Config { | ||
val driver : Driver = ??? | ||
def driver(a: Any) = ??? | ||
} | ||
|
||
object Sites extends Config.driver.Table |
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,19 @@ | ||
object Test { | ||
locally { | ||
Sites: Config.driver.Table | ||
} | ||
} | ||
|
||
// Under separate compilation, the pickler is foiled by the | ||
// overloaded term `Config.driver`, and results in: | ||
|
||
// qbin/scalac test/files/pos/t7596/A_1.scala && qbin/scalac -explaintypes test/files/pos/t7596/B_2.scala | ||
// test/files/pos/t7596/B_2.scala:3: error: type mismatch; | ||
// found : Sites.type | ||
// required: Config.driver.Table | ||
// Sites: Config.driver.Table | ||
// ^ | ||
// Sites.type <: Config.driver.Table? | ||
// Driver.this.type = Config.driver.type? | ||
// false | ||
// false |
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,10 @@ | ||
trait H2Driver{ | ||
abstract class Table[T] | ||
} | ||
|
||
object Config { | ||
val driver : H2Driver = ??? | ||
def driver(app: Any): H2Driver = ??? | ||
} | ||
|
||
class Sites extends Config.driver.Table[String] |
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 @@ | ||
class DAOBase[E]{ | ||
type TableType <: Config.driver.Table[E] | ||
} | ||
class SitesDAO extends DAOBase[String]{ | ||
type TableType = Sites | ||
} |
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,11 @@ | ||
trait Driver { | ||
abstract class Table | ||
} | ||
|
||
object Config { | ||
val driver : Driver = ??? | ||
val driverUniqueName: driver.type = driver | ||
def driver(a: Any) = ??? | ||
} | ||
|
||
object Sites extends Config.driver.Table |
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,9 @@ | ||
object Test { | ||
locally { | ||
Sites: Config.driver.Table | ||
} | ||
} | ||
|
||
// This variation worked by avoiding referring to the | ||
// overloaded term `Config.driver` in the parent type of | ||
// Sites |