Skip to content

Commit

Permalink
ValueOf should be materializable for ThisTypes
Browse files Browse the repository at this point in the history
Added missing case for ThisType in the ValueOf materializer.
  • Loading branch information
milessabin committed Jan 17, 2018
1 parent 9638e85 commit 8b91a3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/typechecker/Implicits.scala
Expand Up @@ -1372,6 +1372,7 @@ trait Implicits {
tp.dealias match {
case ConstantType(c: Constant) => success(Literal(c))
case SingleType(p, v) => success(gen.mkAttributedRef(p, v) setType tp)
case ThisType(sym) => success(gen.mkAttributedThis(sym) setType tp)
case UnitTpe => success(Literal(Constant(())))
case TypeRef(pre, sym, Nil) if sym.isModuleClass => success(gen.mkAttributedRef(pre, sym.sourceModule) setType tp)
case _ => SearchFailure
Expand Down
13 changes: 13 additions & 0 deletions test/files/pos/sip23-valueof-this.scala
@@ -0,0 +1,13 @@
object Test1 {
valueOf[this.type]
}

class Test2 {
valueOf[this.type]
}

class Test3 { self =>
valueOf[self.type]
}

class A { outerSelf => class B { valueOf[outerSelf.type] } }

0 comments on commit 8b91a3b

Please sign in to comment.