Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/scala.reflect/TypeTest

TypeTest

scala.reflect.TypeTest
See theTypeTest companion object
traitTypeTest[-S,T] extendsSerializable

ATypeTest[S, T] contains the logic needed to know at runtime if a value of typeS is an instance ofT.

If a pattern match is performed on a term of types: S that is uncheckable withs.isInstanceOf[T] and the pattern is one of the following forms:

  • t: T
  • t @ X() whereX.unapply takes an argument of typeT then a given instance ofTypeTest[S, T] is summoned and used to perform the test.

Attributes

Companion
object
Source
TypeTest.scala
Graph
Supertypes
classObject
traitMatchable
classAny

Members list

Value members

Abstract methods

defunapply(x:S):Option[x.type &T]

ATypeTest[S, T] can serve as an extractor that matches if and only if a value of typeS is an instance ofT.

ATypeTest[S, T] can serve as an extractor that matches if and only if a value of typeS is an instance ofT.

The compiler tries to turn unchecked type tests in pattern matches into checked ones by wrapping a(_: T) type pattern astt(_: T), wherett is theTypeTest[S, T] instance. Type tests necessary before calling other extractors are treated similarly.SomeExtractor(...) is turned intott(SomeExtractor(...)) ifT inSomeExtractor.unapply(x: T) is uncheckable, but we have an instance ofTypeTest[S, T].

Attributes

Source
TypeTest.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp