Typechecking regression in v3.1.2
See original GitHub issueCompiler version
Works with v3.1.1, fails with v3.1.2 and v3.1.3-RC3.
First bad commit 3ab18a90ac24dba440c498aab6a8f0c763589605
Minimized code
//> using scala "3.1.1"
//> using lib "org.scalacheck::scalacheck:1.16.0"
import scala.reflect.ClassTag
import org.scalacheck.Arbitrary
import org.scalacheck.Gen
trait E[F[_]] {
type T
val value: F[T]
override def toString(): String = s"E($value)"
}
object E {
def apply[F[_], T1](value1: F[T1]) = new E[F] {
type T = T1
val value = value1
}
}
trait TaggedGen[T] {
val tag: ClassTag[T]
val gen: Gen[T]
override def toString(): String = s"TaggedGen($tag, $gen)"
}
type ETaggedGen = E[TaggedGen]
object TaggedGen {
def apply[T: ClassTag: Arbitrary] = new TaggedGen[T] {
val tag = implicitly
val gen = implicitly[Arbitrary[T]].arbitrary
}
def apply[T](tag1: ClassTag[T], gen1: Gen[T]) = new TaggedGen[T] {
val tag = tag1
val gen = gen1
}
val gen: Gen[ETaggedGen] =
Gen.oneOf(
E(apply[Boolean]),
E(apply[Byte]),
E(apply[String])
)
val gen2: Gen[ETaggedGen] =
gen.map { etg =>
implicit val tag = etg.value.tag
E(TaggedGen(tag, etg.value.gen.filter(_ => true))) // <-- failure here
}
}
Output
[error] ./test.sc:54:19: Found: (tag : reflect.ClassTag[etg.T])
[error] Required: reflect.ClassTag[Any]
[error] E(TaggedGen(tag, etg.value.gen.filter(_ => true)))
[error] ^^^
Error compiling project (Scala 3.1.2, JVM)
Expectation
This snippet should continue compiling with scala v3.1.2.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Compilation significantly slower than TSC, and massive ...
Have tried that but it loses all worthwhile type checking. It still takes around 11 seconds on 1.2.1, which is the same speed...
Read more >Sign in - YouTube
Jamovi 1.2 /1.6 Tutorial: Multivariate Linear Regression (Episode 6) ... This tutorial uses the current build of Jamovi, 1.6. 3 on MacOS.
Read more >3.4.3 - Simple Linear Regression | STAT 200
In this course, we will be learning specifically about simple linear regression. The "simple" part is that we will be using only one...
Read more >sklearn.linear_model.LinearRegression
LinearRegression: Principal Component Regression vs Partial Least Squares Regression ... 2])) + 3 >>> reg = LinearRegression().fit(X, y) >>> reg.score(X, ...
Read more >Chapter 12: Regression: Basics, Assumptions, & Diagnostics
'data.frame': 20 obs. of 3 variables: ## $ subjectID: Factor w/ 10 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Workaround: give an explicit result type to E.apply:
Otherwise the inferred type is
E[F] { type T = T1 }
which complicates inference since the typeE[F] { type T = it.T }
is not valid outside the lambda whereit
is defined.So, can we close this?