Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 503ae37

Browse files
committed
Merge pull request #32 from puffnfresh/feature/implicit-ambiguous-annotation
Add an @implicitAmbiguous annotation
2 parents d76ccf3 + 9c3a93e commit 503ae37

17 files changed

+208
-50
lines changed

build-ant-macros.xml

+1
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@
733733

734734
<sequential>
735735
<deploy-one name="scala-library" local="@{local}" signed="@{signed}"/>
736+
<deploy-one name="scala-typelevel" local="@{local}" signed="@{signed}"/>
736737
<deploy-one name="scala-reflect" local="@{local}" signed="@{signed}"/>
737738
<deploy-one name="scala-compiler" local="@{local}" signed="@{signed}"/>
738739

build.xml

+46-4
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ TODO:
349349
<path refid="external-modules.deps.classpath"/>
350350
<rsel:not><rsel:or>
351351
<rsel:name name="scala-library*.jar"/>
352+
<rsel:name name="scala-typelevel*.jar"/>
352353
<rsel:name name="scala-reflect*.jar"/>
353354
<rsel:name name="scala-compiler*.jar"/>
354355
</rsel:or></rsel:not>
@@ -650,7 +651,7 @@ TODO:
650651
<property name="partest-javaagent.description" value="Scala Compiler Testing Tool (compiler-specific java agent)"/>
651652

652653
<!-- projects without project-specific options: asm, forkjoin, manual, bin, repl -->
653-
<for list="actors,compiler,interactive,scaladoc,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml,continuations-plugin,continuations-library" param="project">
654+
<for list="actors,compiler,interactive,scaladoc,library,typelevel,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml,continuations-plugin,continuations-library" param="project">
654655
<sequential>
655656
<!-- description is mandatory -->
656657
<init-project-prop project="@{project}" name="package" default=""/> <!-- used by mvn-package, copy-bundle, make-bundle -->
@@ -732,6 +733,11 @@ TODO:
732733
<path refid="aux.libs"/>
733734
</path>
734735

736+
<path id="quick.typelevel.build.path">
737+
<path refid="quick.library.build.path"/>
738+
<pathelement location="${build-quick.dir}/classes/typelevel"/>
739+
</path>
740+
735741
<path id="quick.actors.build.path">
736742
<path refid="quick.library.build.path"/>
737743
<pathelement location="${build-quick.dir}/classes/actors"/>
@@ -786,6 +792,7 @@ TODO:
786792

787793
<path id="quick.bin.tool.path">
788794
<path refid="quick.repl.build.path"/>
795+
<path refid="quick.typelevel.build.path"/>
789796
<path refid="quick.actors.build.path"/>
790797
<pathelement location="${build-quick.dir}/classes/scalap"/>
791798
<pathelement location="${build-quick.dir}/classes/scaladoc"/>
@@ -795,6 +802,7 @@ TODO:
795802
<!-- PACK -->
796803
<path id="pack.compiler.path">
797804
<pathelement location="${library.jar}"/>
805+
<pathelement location="${typelevel.jar}"/>
798806
<pathelement location="${reflect.jar}"/>
799807
<pathelement location="${compiler.jar}"/>
800808
<pathelement location="${ant.jar}"/>
@@ -804,6 +812,7 @@ TODO:
804812

805813
<path id="pack.bin.tool.path">
806814
<pathelement location="${library.jar}"/>
815+
<pathelement location="${typelevel.jar}"/>
807816
<pathelement location="${xml.jar}"/>
808817
<pathelement location="${parser-combinators.jar}"/>
809818
<pathelement location="${actors.jar}"/>
@@ -820,6 +829,10 @@ TODO:
820829
<fileset dir="${forkjoin-classes}"/>
821830
</path>
822831

832+
<path id="pack.typelevel.files">
833+
<fileset dir="${build-quick.dir}/classes/typelevel"/>
834+
</path>
835+
823836
<path id="pack.actors.files">
824837
<fileset dir="${build-quick.dir}/classes/actors"/>
825838
</path>
@@ -866,6 +879,7 @@ TODO:
866879

867880
<!-- DOCS -->
868881
<path id="docs.library.build.path"> <path refid="quick.library.build.path"/> </path>
882+
<path id="docs.typelevel.build.path"> <path refid="quick.typelevel.build.path"/> </path>
869883
<path id="docs.reflect.build.path"> <path refid="quick.reflect.build.path"/> </path>
870884
<path id="docs.compiler.build.path"> <path refid="quick.compiler.build.path"/> </path>
871885
<path id="docs.scaladoc.build.path"> <path refid="quick.scaladoc.build.path"/> </path>
@@ -877,6 +891,7 @@ TODO:
877891
<path id="scaladoc.classpath">
878892
<path refid="external-modules-nocore"/>
879893
<pathelement location="${library.jar}"/>
894+
<pathelement location="${typelevel.jar}"/>
880895
<pathelement location="${reflect.jar}"/>
881896
<pathelement location="${compiler.jar}"/>
882897

@@ -892,6 +907,7 @@ TODO:
892907
<path id="manual.build.path">
893908
<path refid="external-modules-nocore"/> <!-- xml -->
894909
<pathelement location="${library.jar}"/>
910+
<pathelement location="${typelevel.jar}"/>
895911
<pathelement location="${build.dir}/manmaker/classes"/>
896912
<path refid="aux.libs"/> <!-- for ant -->
897913
</path>
@@ -917,6 +933,7 @@ TODO:
917933
</path>
918934
<path id="partest.compilation.path.core">
919935
<pathelement location="${library.jar}"/>
936+
<pathelement location="${typelevel.jar}"/>
920937
<pathelement location="${reflect.jar}"/>
921938
<pathelement location="${compiler.jar}"/>
922939
</path>
@@ -940,6 +957,7 @@ TODO:
940957
<path refid="partest.classpath"/>
941958
<rsel:not><rsel:or>
942959
<rsel:name name="scala-library*.jar"/>
960+
<rsel:name name="scala-typelevel*.jar"/>
943961
</rsel:or></rsel:not>
944962
</restrict>
945963
<pathelement location="${scala-xml}"/>
@@ -950,6 +968,7 @@ TODO:
950968
<path refid="scalacheck.classpath"/>
951969
<rsel:not><rsel:or>
952970
<rsel:name name="scala-library*.jar"/>
971+
<rsel:name name="scala-typelevel*.jar"/>
953972
<rsel:name name="scala-compiler*.jar"/>
954973
<rsel:name name="scala-reflect*.jar"/>
955974
<rsel:name name="scala-actors*.jar"/>
@@ -977,6 +996,7 @@ TODO:
977996
<path id="test.osgi.compiler.build.path">
978997
<pathelement location="${test.osgi.classes}"/>
979998
<pathelement location="${build-osgi.dir}/org.scala-lang.scala-library.jar"/>
999+
<pathelement location="${build-osgi.dir}/org.scala-lang.scala-typelevel.jar"/>
9801000
<pathelement location="${build-osgi.dir}/org.scala-lang.scala-reflect.jar"/>
9811001
<pathelement location="${build-osgi.dir}/org.scala-lang.scala-compiler.jar"/>
9821002
<pathelement location="${build-osgi.dir}/org.scala-lang.scala-actors.jar"/>
@@ -1091,6 +1111,9 @@ TODO:
10911111
<target name="quick.lib" depends="quick.start">
10921112
<staged-build with="locker" stage="quick" project="library" srcpath="${src.dir}/library" includes="lib.rootdoc.includes"/></target>
10931113

1114+
<target name="quick.typelevel" depends="quick.lib">
1115+
<staged-build with="locker" stage="quick" project="typelevel"/> </target>
1116+
10941117
<target name="quick.reflect" depends="quick.lib">
10951118
<staged-build with="locker" stage="quick" project="reflect"/> </target>
10961119

@@ -1129,6 +1152,8 @@ TODO:
11291152
============================================================================ -->
11301153
<target name="pack.lib" depends="quick.lib, forkjoin.done"> <staged-pack project="library"/></target>
11311154

1155+
<target name="pack.typelevel" depends="quick.typelevel"> <staged-pack project="typelevel"/></target>
1156+
11321157
<target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target>
11331158

11341159
<!-- TODO modularize compiler. Remove other quick targets when they become modules. -->
@@ -1148,7 +1173,7 @@ TODO:
11481173
<copy file="${basedir}/META-INF/MANIFEST.MF" toDir="${build-pack.dir}/META-INF"/>
11491174
<manifest file="${build-pack.dir}/META-INF/MANIFEST.MF" mode="update">
11501175
<attribute name="Bundle-Version" value="${version.number}"/>
1151-
<attribute name="Class-Path" value="scala-reflect.jar scala-library.jar"/>
1176+
<attribute name="Class-Path" value="scala-reflect.jar scala-library.jar scala-typelevel.jar"/>
11521177
</manifest>
11531178
</pre>
11541179
<!-- JSR-223 support introduced in 2.11 -->
@@ -1167,7 +1192,7 @@ TODO:
11671192

11681193
<target name="pack.scalap" depends="quick.scalap"> <staged-pack project="scalap"/> </target>
11691194

1170-
<target name="pack.core" depends="pack.reflect, pack.comp, pack.lib"/>
1195+
<target name="pack.core" depends="pack.reflect, pack.comp, pack.lib, pack.typelevel"/>
11711196

11721197
<!-- TODO modularize compiler: pack.scaladoc, pack.interactive, -->
11731198
<target name="pack.modules" depends="pack.actors, pack.scalap">
@@ -1233,6 +1258,7 @@ TODO:
12331258
</fileset>
12341259
<filelist>
12351260
<file name="${library.jar}"/>
1261+
<file name="${typelevel.jar}"/>
12361262
<file name="${reflect.jar}"/>
12371263
<file name="${compiler.jar}"/>
12381264
</filelist>
@@ -1245,6 +1271,10 @@ TODO:
12451271
<fileset dir="${src.dir}/library"/>
12461272
</make-bundle>
12471273

1274+
<make-bundle project="typelevel">
1275+
<fileset dir="${src.dir}/typelevel"/>
1276+
</make-bundle>
1277+
12481278
<make-bundle project="reflect">
12491279
<fileset dir="${src.dir}/reflect"/>
12501280
</make-bundle>
@@ -1574,6 +1604,12 @@ TODO:
15741604
</staged-docs>
15751605
</target>
15761606

1607+
<target name="docs.typelevel" depends="docs.start" unless="docs.skip">
1608+
<staged-docs project="typelevel">
1609+
<include name="**/*.scala"/>
1610+
</staged-docs>
1611+
</target>
1612+
15771613
<target name="docs.reflect" depends="docs.start" unless="docs.skip">
15781614
<staged-docs project="reflect">
15791615
<include name="**/*.scala"/>
@@ -1617,7 +1653,7 @@ TODO:
16171653
</staged-docs>
16181654
</target>
16191655

1620-
<target name="docs.core" depends="docs.lib, docs.reflect, docs.comp" unless="docs.skip"/>
1656+
<target name="docs.core" depends="docs.lib, docs.typelevel, docs.reflect, docs.comp" unless="docs.skip"/>
16211657
<!-- TODO modularize compiler: docs.scaladoc, docs.interactive, -->
16221658
<target name="docs.done" depends="docs.core, docs.actors, docs.scalap" unless="docs.skip"/>
16231659

@@ -1673,6 +1709,7 @@ MAIN DISTRIBUTION PACKAGING
16731709
<mkdir dir="${dist.maven}"/>
16741710

16751711
<mvn-package project="library"/>
1712+
<mvn-package project="typelevel"/>
16761713
<mvn-package project="reflect"/>
16771714
<mvn-package project="compiler"/>
16781715

@@ -1737,30 +1774,35 @@ MAIN DISTRIBUTION PACKAGING
17371774
<target name="publish" depends="pack-maven.done, init.maven" description="Publishes unsigned artifacts to the maven repo.">
17381775
<deploy />
17391776
<deploy-pom name="scala-library-all"/>
1777+
<deploy-jar name="scala-typelevel"/>
17401778
<deploy-jar name="scala-dist"/>
17411779
</target>
17421780

17431781
<target name="publish.local" depends="pack-maven.done, init.maven" description="Publishes unsigned artifacts to the local maven repo.">
17441782
<deploy local="true"/>
17451783
<deploy-pom name="scala-library-all" local="true"/>
1784+
<deploy-jar name="scala-typelevel" local="true"/>
17461785
<deploy-jar name="scala-dist" local="true"/>
17471786
</target>
17481787

17491788
<target name="publish.signed" depends="pack-maven.done, init.maven" description="Publishes signed artifacts to the remote maven repo.">
17501789
<deploy signed="true"/>
17511790
<deploy-pom name="scala-library-all" signed="true"/>
1791+
<deploy-jar name="scala-typelevel" signed="true"/>
17521792
<deploy-jar name="scala-dist" signed="true"/>
17531793
</target>
17541794

17551795
<target name="publish-core" depends="pack-maven.core, init.maven">
17561796
<deploy-one name="scala-compiler" />
17571797
<deploy-one name="scala-library" />
1798+
<deploy-one name="scala-typelevel" />
17581799
<deploy-one name="scala-reflect" />
17591800
</target>
17601801

17611802
<target name="publish-core-local" depends="pack-maven.core, init.maven">
17621803
<deploy-one name="scala-compiler" local="true"/>
17631804
<deploy-one name="scala-library" local="true"/>
1805+
<deploy-one name="scala-typelevel" local="true"/>
17641806
<deploy-one name="scala-reflect" local="true"/>
17651807
</target>
17661808

src/build/bnd/scala-typelevel.bnd

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Bundle-Name: Scala Typelevel Library
2+
Bundle-SymbolicName: org.scala-lang.scala-typelevel
3+
ver: @VERSION@
4+
Bundle-Version: ${ver}
5+
Export-Package: *;version=${ver}
6+
Import-Package: scala.*;version="${range;[==,=+);@VERSION@}",*
7+
Bundle-RequiredExecutionEnvironment: JavaSE-1.6, JavaSE-1.7

src/build/maven/scala-dist-pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
<artifactId>scala-library-all</artifactId>
3535
<version>@VERSION@</version>
3636
</dependency>
37+
<dependency>
38+
<groupId>org.scala-lang</groupId>
39+
<artifactId>scala-typelevel</artifactId>
40+
<version>@VERSION@</version>
41+
</dependency>
3742
<dependency>
3843
<groupId>org.scala-lang</groupId>
3944
<artifactId>scala-compiler</artifactId>
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.scala-lang</groupId>
5+
<artifactId>scala-typelevel</artifactId>
6+
<packaging>jar</packaging>
7+
<version>@VERSION@</version>
8+
<name>Scala Typelevel Library</name>
9+
<description>Typelevel Library for the Typelevel Scala Compiler</description>
10+
<url>http://typelevel.org/</url>
11+
<inceptionYear>2014</inceptionYear>
12+
<organization>
13+
<name>Typelevel</name>
14+
<url>http://typelevel.org/</url>
15+
</organization>
16+
<licenses>
17+
<license>
18+
<name>BSD 3-Clause</name>
19+
<url>http://www.scala-lang.org/license.html</url>
20+
<distribution>repo</distribution>
21+
</license>
22+
</licenses>
23+
<scm>
24+
<connection>scm:git:git://github.com/typelevel/scala.git</connection>
25+
<url>https://github.com/typelevel/scala.git</url>
26+
</scm>
27+
<issueManagement>
28+
<system>GitHub</system>
29+
<url>https://github.com/typelevel/scala/issues/</url>
30+
</issueManagement>
31+
<properties>
32+
<info.apiURL>http://www.scala-lang.org/api/@VERSION@/</info.apiURL>
33+
</properties>
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.scala-lang</groupId>
37+
<artifactId>scala-library</artifactId>
38+
<version>@VERSION@</version>
39+
</dependency>
40+
</dependencies>
41+
<developers>
42+
<developer>
43+
<id>typelevel</id>
44+
<name>Typelevel</name>
45+
</developer>
46+
</developers>
47+
</project>

src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala

+15-4
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,8 @@ trait ContextErrors {
11951195

11961196
import definitions._
11971197

1198-
def AmbiguousImplicitError(info1: ImplicitInfo, info2: ImplicitInfo,
1198+
def AmbiguousImplicitError(info1: ImplicitInfo, tree1: Tree,
1199+
info2: ImplicitInfo, tree2: Tree,
11991200
pre1: String, pre2: String, trailer: String)
12001201
(isView: Boolean, pt: Type, tree: Tree)(implicit context0: Context) = {
12011202
if (!info1.tpe.isErroneous && !info2.tpe.isErroneous) {
@@ -1231,10 +1232,20 @@ trait ContextErrors {
12311232
if (explanation == "") "" else "\n" + explanation
12321233
)
12331234
}
1235+
1236+
def treeTypeArgs(annotatedTree: Tree) = annotatedTree match {
1237+
case TypeApply(_, args) => args.map(_.toString)
1238+
case _ => Nil
1239+
}
1240+
12341241
context.issueAmbiguousError(AmbiguousImplicitTypeError(tree,
1235-
if (isView) viewMsg
1236-
else s"ambiguous implicit values:\n${coreMsg}match expected type $pt")
1237-
)
1242+
(tree1.symbol, tree2.symbol) match {
1243+
case (ImplicitAmbiguousMsg(msg), _) => msg.format(treeTypeArgs(tree1))
1244+
case (_, ImplicitAmbiguousMsg(msg)) => msg.format(treeTypeArgs(tree2))
1245+
case (_, _) if isView => viewMsg
1246+
case (_, _) => s"ambiguous implicit values:\n${coreMsg}match expected type $pt"
1247+
}
1248+
))
12381249
}
12391250
}
12401251

0 commit comments

Comments
 (0)