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

Mixer bug for non-primitives #20

Merged
merged 5 commits into from
Jul 9, 2019
Merged
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.typechecked
package alphabetsoup

import io.typechecked.alphabetsoup.macros.Atomic
import org.scalatest.FlatSpec
import org.scalatest.Matchers
import shapeless.::
Expand Down Expand Up @@ -36,6 +37,34 @@ class MixerSpec extends FlatSpec with Matchers {
Mixer[A1, A1].mix(A1(5, "hello")) shouldBe A1(5, "hello")
}

it should "select smaller type from larger for primitives" in {
implicitly[Mixer[(String, Int), Int]]
implicitly[Mixer[(String, Int), String]]
}

it should "select smaller type from larger for non-primitives" in {

@Atomic class A
@Atomic class B

pendingUntilFixed{
"implicitly[Mixer[(A, B), B]]" should compile
}

@Atomic trait C
@Atomic trait D

implicitly[Mixer[(C, D), D]]
implicitly[Mixer[(C, D), C]]

@Atomic case class E()
@Atomic case class F()

pendingUntilFixed{
"implicitly[Mixer[(E, F), F]]" should compile
}
}

it should "not work on mis-matched simple types" in {
illTyped("""Mixer[Int, String]""")
}
Expand Down