Permalink
Browse files

Fix an inference regression with this.type.

Closes SI-5210.
  • Loading branch information...
paulp committed May 9, 2012
1 parent 1cd498f commit 09f380dbda56abdfbdda0cab51bc7187eb70b516
Showing with 28 additions and 2 deletions.
  1. +2 −2 src/compiler/scala/tools/nsc/typechecker/Namers.scala
  2. +10 −0 test/files/pos/t5210.scala
  3. +16 −0 test/pending/pos/z1720.scala
@@ -787,8 +787,8 @@ trait Namers extends MethodSynthesis {
val typedBody =
if (tree.symbol.isTermMacro) defnTyper.computeMacroDefType(tree, pt)
else defnTyper.computeType(tree.rhs, pt)
- val sym = if (owner.isMethod) owner else tree.symbol
- val typedDefn = widenIfNecessary(sym, typedBody, pt)
+
+ val typedDefn = widenIfNecessary(tree.symbol, typedBody, pt)
assignTypeToTree(tree, typedDefn)
}
View
@@ -0,0 +1,10 @@
+object WithOpTest {
+ trait WithOp extends Cloneable {
+ def f: this.type = this
+ def g1: this.type = f
+ def g2: this.type = {
+ val t = f
+ t
+ }
+ }
+}
@@ -0,0 +1,16 @@
+package test
+
+class Thing {
+ def info: Info[this.type] = InfoRepository.getInfo(this)
+ def info2: Info[this.type] = {
+ def self: this.type = this
+ InfoRepository.getInfo(self)
+ }
+}
+
+trait Info[T]
+case class InfoImpl[T](thing: T) extends Info[T]
+
+object InfoRepository {
+ def getInfo(t: Thing): Info[t.type] = InfoImpl(t)
+}

0 comments on commit 09f380d

Please sign in to comment.