diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t5210.scala | 10 | ||||
-rw-r--r-- | test/pending/pos/z1720.scala | 16 |
3 files changed, 28 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 063db4bb88..ca4b1d3de8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.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) } diff --git a/test/files/pos/t5210.scala b/test/files/pos/t5210.scala new file mode 100644 index 0000000000..e85037a902 --- /dev/null +++ b/test/files/pos/t5210.scala @@ -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 + } + } +} diff --git a/test/pending/pos/z1720.scala b/test/pending/pos/z1720.scala new file mode 100644 index 0000000000..6050f3ff88 --- /dev/null +++ b/test/pending/pos/z1720.scala @@ -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) +}
\ No newline at end of file |