diff options
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 4 | ||||
-rw-r--r-- | test/files/run/t7876.scala | 26 | ||||
-rw-r--r-- | test/scaladoc/run/t7876.check | 1 | ||||
-rw-r--r-- | test/scaladoc/run/t7876.scala | 19 |
4 files changed, 48 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index f8af4f155d..961e8e7264 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -658,8 +658,8 @@ trait Definitions extends api.StandardDefinitions { // These "direct" calls perform no dealiasing. They are most needed when // printing types when one wants to preserve the true nature of the type. - def isFunctionTypeDirect(tp: Type) = isFunctionSymbol(tp.typeSymbolDirect) - def isTupleTypeDirect(tp: Type) = isTupleSymbol(tp.typeSymbolDirect) + def isFunctionTypeDirect(tp: Type) = !tp.isHigherKinded && isFunctionSymbol(tp.typeSymbolDirect) + def isTupleTypeDirect(tp: Type) = !tp.isHigherKinded && isTupleSymbol(tp.typeSymbolDirect) // Note that these call .dealiasWiden and not .normalize, the latter of which // tends to change the course of events by forcing types. diff --git a/test/files/run/t7876.scala b/test/files/run/t7876.scala new file mode 100644 index 0000000000..aeec8c8cce --- /dev/null +++ b/test/files/run/t7876.scala @@ -0,0 +1,26 @@ +import scala.tools.partest._ + +// Type constructors for FunctionN and TupleN should not be considered as function type / tuple types. +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp" + + def code = "" + + def show() { + val global = newCompiler() + new global.Run() + import global._, definitions._ + val function0TC = FunctionClass(0).typeConstructor + val tuple1TC = TupleClass(1).typeConstructor + FunctionClass.seq.foreach { sym => + val tc = sym.typeConstructor + assert(!isFunctionType(tc), s"$tc") + assert(!isFunctionTypeDirect(tc), s"$tc (direct)") + } + TupleClass.seq.foreach { sym => + val tc = sym.typeConstructor + assert(!isTupleType(tc), s"$sym") + assert(!isTupleTypeDirect(tc), s"$tc (direct)") + } + } +} diff --git a/test/scaladoc/run/t7876.check b/test/scaladoc/run/t7876.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/t7876.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/t7876.scala b/test/scaladoc/run/t7876.scala new file mode 100644 index 0000000000..63c63f8a0c --- /dev/null +++ b/test/scaladoc/run/t7876.scala @@ -0,0 +1,19 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = """ + import language.higherKinds + trait T[M[_]] + class C extends T[Function0] + class D extends T[Tuple1] + """ + + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import access._ + // did not crash + } +} |