Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
Add assert that refine infos are legal wrt refined names
  • Loading branch information
odersky committed Feb 27, 2017
commit 7a14c056708e2e5db4382e0f7466882c66de87c8
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,9 @@ object Types {
*/
abstract case class RefinedType(parent: Type, refinedName: Name, refinedInfo: Type) extends RefinedOrRecType {

if (refinedName.isTermName) assert(refinedInfo.isInstanceOf[TermType])
else assert(refinedInfo.isInstanceOf[TypeType])

override def underlying(implicit ctx: Context) = parent

private def badInst =
Expand Down
1 change: 1 addition & 0 deletions tests/run/i2037.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
malformed type
26 changes: 26 additions & 0 deletions tests/run/i2037.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import dotty.tools.dotc._
import core._
import Types._
import Contexts._
import Symbols._
import Decorators._

object Test {
def f(implicit ctx: Context) = {
val badType =
RefinedType(
ctx.requiredClassRef("scala.collection.AbstractIterator"),
"GroupedIterator".toTypeName,
TypeRef(ctx.requiredClassRef("scala.collection.AbstractIterator"), "GroupedIterator".toTypeName))
badType.member("GroupedIterator".toTypeName)
// badType.member("T".toTypeName)
}
def main(args: Array[String]): Unit = {
implicit val ctx = (new ContextBase).initialCtx
ctx.base.initialize()
try f
catch {
case ex: AssertionError => println("malformed type")
}
}
}