Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#110 #120

Merged
merged 4 commits into from
Nov 21, 2023
Merged

#110 #120

Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}

dependencies {
classpath("ch.epfl.scala:gradle-bloop_2.12:1.6.1") // suffix is always 2.12, weird
classpath("ch.epfl.scala:gradle-bloop_2.12:1.6.2") // suffix is always 2.12, weird
}
}

Expand All @@ -33,7 +33,7 @@ plugins {
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"

id("com.github.ben-manes.versions") version "0.49.0"
id("com.github.ben-manes.versions") version "0.50.0"

id("io.github.cosmicsilence.scalafix") version "0.1.14"
}
Expand Down Expand Up @@ -144,7 +144,7 @@ allprojects {

val scalaTestV = "3.2.11"
testFixturesApi("org.scalatest:scalatest_${vs.scalaBinaryV}:${scalaTestV}")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")

testRuntimeOnly("co.helmethair:scalatest-junit-runner:0.2.0")
}
Expand Down Expand Up @@ -358,6 +358,7 @@ idea {
".gradle",
"gradle",
"spike",
".history"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,17 @@ trait SplainFormattingExtension extends typechecker.splain.SplainFormatting with

if (isAux(tpe)) tpe
else {

val result = tpe.dealias
result
val result = tpe.dealias.normalize
result match {
case p: PolyType =>
val target = dealias(p.resultType)
val _p = p.copy(
resultType = target
)
_p
case _ =>
result
}
}
}

Expand Down Expand Up @@ -608,11 +616,11 @@ trait SplainFormattingExtension extends typechecker.splain.SplainFormatting with

protected def formatDiffImplNoDisambiguation(found: Type, req: Type, top: Boolean): Formatted = {

val (left, right) = dealias(found) -> dealias(req)
val reduced = Seq(found, req).map(dealias)
val Seq(left, right) = reduced

val normalized = Seq(left, right).map(_.normalize).distinct
if (normalized.size == 1) {
val only = normalized.head
if (reduced.distinct.size == 1) {
val only = reduced.head
val result = formatType(only, top)

val basedOn = Seq(found, req).distinct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ trait TyperCompatViews {

case class TypeView(self: Type) {

lazy val extractArgs: List[global.Type] = self match {
// PolyType handling is removed for being unsound
case t: AliasTypeRef if !isAux(self) =>
t.betaReduce.typeArgs.map(a => if (a.typeSymbolDirect.isTypeParameter) WildcardType else a)
case _ => self.typeArgs
lazy val extractArgs: List[global.Type] = {

self.typeArgs
}

lazy val noArgType: Type = if (extractArgs.nonEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,7 @@ f invalid because
implicitly[String]
^
newSource1.scala:11: error: implicit error;
!I e:
DeepHole.C1[
DeepHole.T3[
DeepHole.T1[List[String], ?],
DeepHole.T2[DeepHole.Id, DeepHole.C4, ?],
?
]
]
!I e: DeepHole.C1[[Z]DeepHole.C2[DeepHole.T1,DeepHole.T2,Z]]
implicitly[C1[T3]]
^
newSource1.scala:9: error: implicit error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ val x: vecInt.Head = ??? : Option[String]
^
newSource1.scala:8: error: implicit error;
!I e:
Option[Int] (reduced from) { FoundReqVsImplicit.vecInt.Head[Int] } =:=
Option[Int] (reduced from) { FoundReqVsImplicit.vecInt.Head } =:=
Option[String]
Cannot prove that FoundReqVsImplicit.vecInt.Head =:= Option[String].

Expand All @@ -19,6 +19,6 @@ implicitly[vecInt.Head =:= Option[String]]
newSource1.scala:10: error: type mismatch;
Option[String|Int]
――(right side reduced from)
FoundReqVsImplicit.vecInt.Head[Int]
FoundReqVsImplicit.vecInt.Head
val x: vecInt.Head = ??? : Option[String]
^
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,21 @@ newSource1.scala:16: error: implicit error;
――(defined at newSource1.scala:8:13)
wrongf(new A)
^
newSource1.scala:5: error: implicit error;
!I e: String :: Int :: Boolean
implicitly[K]
^
newSource1.scala:7: error: type mismatch;
String("abc")|String :: Int :: Boolean
def v: K = "abc"
^
newSource1.scala:5: error: implicit error;
!I e: String :: Int :: Boolean (reduced from) { Test.K }
implicitly[K]
^
newSource1.scala:7: error: type mismatch;
String("abc")|String :: Int :: Boolean
――(right side reduced from)
Test.K
def v: K = "abc"
^
19 changes: 19 additions & 0 deletions core/src/test/scala/splain/plugin/VTypeDetailSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ class VTypeDetailSpec extends SpecBase.Direct {
}
"""

final val reduceToInfix =
"""
object Test {
trait ::[A, B]

type K = String :: Int :: Boolean
implicitly[K]

def v: K = "abc"
}
"""

describe("#113") {

check(wrongContexts, profile = "-P:splain:Vtype-detail:1", numberOfErrors = 2)
Expand All @@ -40,4 +52,11 @@ class VTypeDetailSpec extends SpecBase.Direct {
check(wrongContexts, profile = "-P:splain:Vtype-detail:6", numberOfErrors = 2)
}

describe("#119") {

check(reduceToInfix, profile = "-P:splain:Vtype-detail:3", numberOfErrors = 2)

check(reduceToInfix, profile = "-P:splain:Vtype-detail:4", numberOfErrors = 2)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,7 @@ f invalid because
newSource1.scala:11: error: implicit error;
!I e:
splain.acceptance.builtin.StaticBasicSpec.DeepHole.C1[
splain.acceptance.builtin.StaticBasicSpec.DeepHole.T3[
splain.acceptance.builtin.StaticBasicSpec.DeepHole.T1[List[String], ?],
splain.acceptance.builtin.StaticBasicSpec.DeepHole.T2[
splain.acceptance.builtin.StaticBasicSpec.DeepHole.Id,
splain.acceptance.builtin.StaticBasicSpec.DeepHole.C4,
?
],
?
]
[Z]splain.acceptance.builtin.StaticBasicSpec.DeepHole.C2[splain.acceptance.builtin.StaticBasicSpec.DeepHole.T1,splain.acceptance.builtin.StaticBasicSpec.DeepHole.T2,Z]
]
implicitly[C1[T3]]
^
Expand Down
Loading