PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/orc/error/compiletime/typing/TypeExceptions.scala

https://github.com/laurenyew/cOrcS
Scala | 87 lines | 39 code | 31 blank | 17 comment | 0 complexity | 7098f7f6da63c2dfcb937a522c9e1f4d MD5 | raw file
Possible License(s): BSD-3-Clause
  1. //
  2. // TypeExceptions.scala -- Scala child classes of TypeException
  3. // Project OrcScala
  4. //
  5. // $Id: TypeExceptions.scala 3109 2012-10-02 20:38:58Z laurenyew $
  6. //
  7. // Created by jthywiss on Aug 11, 2010.
  8. //
  9. // Copyright (c) 2011 The University of Texas at Austin. All rights reserved.
  10. //
  11. // Use and redistribution of this file is governed by the license terms in
  12. // the LICENSE file found in the project's top-level directory and also found at
  13. // URL: http://orc.csres.utexas.edu/license.shtml .
  14. //
  15. package orc.error.compiletime.typing
  16. import orc.types.Type
  17. import orc.values.Field
  18. import orc.error.compiletime._
  19. class ArgumentArityException(val arityExpected: Int, val arityReceived: Int) extends TypeException("Expected " + arityExpected + " arguments to call, got " + arityReceived + " arguments instead.") with SeverityError
  20. class TypeArgumentArityException(val arityExpected: Int, val arityReceived: Int) extends TypeException("Expected " + arityExpected + " type arguments to call, got " + arityReceived + " arguments instead.") with SeverityError
  21. class DefinitionArityException(val arityFromType: Int, val arityFromSyntax: Int) extends TypeException("Definition should have " + arityFromType + " arguments according to its type, observed " + arityFromSyntax + " arguments instead.") with SeverityError
  22. class ArgumentTypecheckingException(val argPosition: Int, val expectedType: Type, val providedType: Type) extends TypeException("Expected type " + expectedType + " or some subtype for argument " + argPosition + ", got " + providedType + " instead")
  23. /* Stub type for error messages to describe a missing type which might not be constructible
  24. * directly as a type, for example "a tuple of any size".
  25. */
  26. case class ExpectedType(description: String) extends Type { override def toString = description }
  27. class MissingTypeException() extends TypeException("Type checker failed: couldn't obtain sufficient type information from a service or value.") with SeverityError
  28. class OverloadedTypeException(val specificMessages: List[String] = Nil) extends TypeException("All alternatives for overloaded type failed to typecheck.\n" + specificMessages.mkString("\n")) with SeverityError {
  29. def addAlternative(t: Type, e: TypeException) =
  30. new OverloadedTypeException((t + " failed due to error: \n" + e) :: specificMessages)
  31. }
  32. class SubtypeFailureException(val expectedType: Type, val receivedType: Type) extends TypeException("Expected type " + expectedType + " or some subtype, found type " + receivedType + " instead.") with SeverityError
  33. class FunctionTypeExpectedException(val receivedType: Type) extends TypeException("Expected a function type, found type " + receivedType + " instead.") with SeverityError
  34. class TypeArityException(val arityExpected: Int, val arityReceived: Int) extends TypeException("Expected " + arityExpected + " arguments to type instantiation, got " + arityReceived + " arguments instead.") with SeverityError
  35. class UnboundTypeException(val typeName: String) extends TypeException("Type " + typeName + " is undefined") with SeverityError
  36. class UncallableTypeException(val t: Type) extends TypeException("Type " + t + " cannot be called as a site or function.") with SeverityError
  37. class UnrepresentableTypeException(val t: Type) extends TypeException(t.toString() + " has no concrete representation.") with SeverityError
  38. class TypeArgumentInferenceFailureException() extends TypeException("Could not infer missing type arguments; please add explicit type arguments") with SeverityError
  39. class UnspecifiedArgTypesException() extends TypeException("Could not infer missing argument types; please add argument type annotations") with SeverityError
  40. class UnspecifiedReturnTypeException() extends TypeException("Could not infer missing return type; please add a return type annotation") with SeverityError
  41. class FirstOrderTypeExpectedException(val nonFirstOrderType: String) extends TypeException("Kinding error: expected a first-order type, found " + nonFirstOrderType + " instead.") with SeverityError
  42. class SecondOrderTypeExpectedException(val nonSecondOrderType: String) extends TypeException("Kinding error: expected a type operator, found " + nonSecondOrderType + " instead.") with SeverityError
  43. class NoMinimalTypeException() extends TypeException("Inference failed; could not find a minimal type. Please add explicit type information.") with SeverityError
  44. class OverconstrainedTypeVariableException() extends TypeException("A type argument is overconstrained; inference failed. Please add explicit type arguments. There may also be an underlying type error.") with SeverityError
  45. class NoBoundedPolymorphismException() extends TypeException("Bounded polymorphism is not yet supported by the Orc typechecker.")
  46. class NoJavaTypeBoundsException() extends TypeException("Can't handle nontrivial type bounds (... extends T) on Java types; bounded polymorphism is not yet supported by the Orc typechecker.")
  47. class TypeResolutionException(val typeName: String, cause: Throwable)
  48. extends CompilationException("Problem loading type " + typeName + ": " + cause.getMessage(), cause) with SeverityError
  49. class TypeOperatorResolutionException(val typeOperatorName: String, cause: Throwable)
  50. extends CompilationException("Problem loading type operator " + typeOperatorName, cause) with SeverityError
  51. class TupleSizeException(val sizeExpected: Int, val sizeReceived: Int) extends TypeException("Expected a tuple of size " + sizeExpected + ", got size " + sizeReceived + " instead.") with SeverityError
  52. class RecordShapeMismatchException(val nonconformingRecordType: orc.types.RecordType, val missingField: String) extends TypeException("Type " + nonconformingRecordType + " is missing field " + missingField + ", which is required by this record pattern.") with SeverityError
  53. class NoSuchMemberException(t: Type, missingMember: String) extends TypeException("Type " + t + " has no member named " + missingMember) with SeverityError
  54. class MalformedDatatypeCallException() extends TypeException("Expected an instance of the datatype as a type argument")
  55. class NoMatchingConstructorException() extends TypeException("No matching constructor found for the types of these arguments")
  56. class SecurityException(val description: String, cause: Throwable) extends TypeException(description)